<?php
/**
 * Created by PhpStorm.
 * User: 12133
 * Date: 2024/3/16
 * Time: 14:23
 */

namespace app\model\index;


use think\model\concern\SoftDelete;

class OrderInfo extends Base
{
    use SoftDelete;
    protected $append = [
        'type_text',
        'keywords_data',
        'price_type_text'
    ];

    public function getKeywordsDataAttr($value,$data){
        return $this->hasOne(Keyword::class,'keyword','keyword');
    }

    public function getKeywordAreaAttr($value){
        if ($value == 'baidu')
            return '百度';
        else if($value == 'douying')
            return '抖音';
        else
            return '全平台';
    }
    public function getTypeTextAttr($value,$data){
        $array = [
            1 => '全端',
            2 => 'PC端',
            3 => '手机端',
            4 => '主词',
            5 => '副词'
        ];
        return $array[$data['type']];
    }
    public function getPriceTypeTextAttr($value,$data){
        $price_type_text = $data['price_type'] == 1 ? '正常' : 'ocpc';
        return $price_type_text;
    }
    public function orderData(){
        return $this->hasOne(Order::class,'order_no','order_no');
    }
}